import { DoubleSide, ExtrudeBufferGeometry, Group, Mesh, MeshBasicMaterial, MeshLambertMaterial, Shape, ShapeGeometry, SphereGeometry, Vector2 } from 'three';

function createExtruMesh(polygonArr, height){
    const shapeArr = [];
    polygonArr.forEach(polygon=>{
        const pointArr = [];
        polygon[0].forEach(elem=>{
            (<any>pointArr).push(new Vector2(elem[0], elem[1]));
        });
        const shape = new Shape(pointArr);
        (<any>shapeArr).push(shape); //shape数组
    });
        const geometry = new ExtrudeBufferGeometry(shapeArr, {
            depth :height,
            bevelEnabled: false //无倒角
            
        });
        const material = new MeshLambertMaterial({
        color:0x004444,
        side:DoubleSide
    });
    const mesh = new Mesh(geometry, material);
    return mesh;
}

export { createExtruMesh };